package 组合数.杨辉三角2;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @className: yhsj2
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-04 14:22
 **/
public class yhsj2 {
    public static void main(String[] args) {
        System.out.println(getRow(3));
    }
    public static List<Integer> getRow(int rowIndex) {
        List<List<Integer>> result = new ArrayList();
        List<Integer> item = new ArrayList();
        item.add(1);
        result.add(item);
        for(int i = 1; i < rowIndex + 1; ++i){
            item = new ArrayList();
            for(int j = i;j >= 0; --j ){
                System.out.println("i "+i+" j "+j);
//                System.out.println("j>=result.get(i-1).size() "+(j >= result.get(i-1).size()));
                System.out.println("size "+(result.get(i-1).size()));
                int one = j >= result.get(i-1).size()?0:result.get(i-1).get(j);
                int two = j-1 < 0?0:result.get(i-1).get(j-1);
                item.add(one+two);
            }
            result.add(item);
        }
        return result.get(rowIndex);
    }

}
